/**
 * 取消订单
 * @returns {Promise<void>}
 */
export const cancelOrder = async (id, fn) => {
    const confirm = await qly.dialog.messageBox({
        title: '提示',
        message: '取消订单后，将无法恢复，请确认是否取消订单?'
    })
    if (confirm) {
        
        const res = await qly.api.order.cancel_order({id})
        if (res.code === 1) {
            qly.dialog.success(res.msg)
            fn && fn()
        } else {
            qly.dialog.apiError(res).catch()
        }
    }
}

/**
 * 取消订单
 * @returns {Promise<void>}
 */
export const orderPay = async (id, fn) => {
    const res = await qly.api.order.order_pay({id})
    if (res.code === 1) {
        qly.dialog.success(res.msg)
        fn && fn()
    } else {
        qly.dialog.apiError(res).catch()
    }
}

/**
 * 确认收货
 * @returns {Promise<void>}
 */
export const confirmReceiving = async (id, fn) => {
    const confirm = await qly.dialog.messageBox({
        title: '提示',
        message: '是否确认收货?'
    })
    if (confirm) {
        const res = await qly.api.order.receiving({id})
        if (res.code === 1) {
            qly.dialog.success(res.msg)
            fn && fn()
        } else {
            qly.dialog.apiError(res).catch()
        }
    }
}
